package com.li.springboard.controller;

import com.li.springboard.pojo.Customer;
import com.li.springboard.service.impl.CustomerServiceImpl;
import org.jetbrains.annotations.Nullable;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * (customer)表控制层
 *
 * @author xxxxx
 */
@RestController
public class CustomerController {
    /**
     * 服务对象
     */
    @Resource
    private CustomerServiceImpl customerServiceImpl;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Customer selectOne(Integer id) {
        return customerServiceImpl.selectByPrimaryKey(id);
    }

    @RequestMapping("/cul")
    public String selectByAll(Customer customer, @Nullable Model model) {
        List<Customer> customers = customerServiceImpl.selectByAll(customer);
        model.addAttribute("crust", customers);
        return "cus/customers";
    }

}
